package lambda;

import java.util.ArrayList;
import java.util.function.Predicate;

public class PredicateTest {
    public static void main(String[] args) {


        String[] arr = {"lqx,30", "liuYan,34", "wzy,35", "diaChan,31"};

        ArrayList<String> strings = checkString(arr, s1 -> {
            String[] split = s1.split(",");
            return split[0].length() > 2;
        }, s1 -> {
            String[] split = s1.split(",");
            return Integer.parseInt(split[1]) > 33;
        });
        for (String st :
                strings) {
            System.out.println(st);
        }
    }

    private static ArrayList<String> checkString(String[] arr, Predicate<String> pre1, Predicate<String> pre2) {
        ArrayList<String> strings = new ArrayList<String>();
        for (String s : arr
        ) {
            if (pre1.and(pre2).test(s)) {
                strings.add(s);
            }
        }

        return strings;
    }
}
